const http = require("http");
const fs = require("fs");
const path = require("path");
const serve = http.createServer();
var dirname = "static"
serve.on("request", (req, res) => {
    console.log(req.url);
    console.log(req.method);
    var filepath = path.join(__dirname, dirname, req.url)
    if (req.url == "/") {
        filepath = path.join(__dirname, dirname, "index.html")
    }
    if (req.url == "/favicon.ico") {
        filepath = path.join(__dirname, dirname, "img", "120px-八奈見杏菜.jpg")
    }
    var data = fs.readFileSync(filepath);
    res.end(data);
});
serve.listen("3000", () => {
    console.log("服务启动成功,请访问http://10.10.35.77:3000/,或http://127.0.0.1:3000/,或http://localhost:3000/");
})